package com.ruoyi.scenery.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.scenery.domain.SceneryStoreTurnover;
import com.ruoyi.scenery.service.ISceneryStoreTurnoverService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 营收管理Controller
 * 
 * @author ruoyi
 * @date 2023-04-09
 */
@RestController
@RequestMapping("/scenery/turnover")
public class SceneryStoreTurnoverController extends BaseController
{
    @Autowired
    private ISceneryStoreTurnoverService sceneryStoreTurnoverService;

    /**
     * 查询营收管理列表
     */
    @PreAuthorize("@ss.hasPermi('scenery:turnover:list')")
    @GetMapping("/list")
    public TableDataInfo list(SceneryStoreTurnover sceneryStoreTurnover)
    {
        startPage();
        List<SceneryStoreTurnover> list = sceneryStoreTurnoverService.selectSceneryStoreTurnoverList(sceneryStoreTurnover);
        return getDataTable(list);
    }

    /**
     * 导出营收管理列表
     */
    @PreAuthorize("@ss.hasPermi('scenery:turnover:export')")
    @Log(title = "营收管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SceneryStoreTurnover sceneryStoreTurnover)
    {
        List<SceneryStoreTurnover> list = sceneryStoreTurnoverService.selectSceneryStoreTurnoverList(sceneryStoreTurnover);
        ExcelUtil<SceneryStoreTurnover> util = new ExcelUtil<SceneryStoreTurnover>(SceneryStoreTurnover.class);
        util.exportExcel(response, list, "营收管理数据");
    }

    /**
     * 获取营收管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('scenery:turnover:query')")
    @GetMapping(value = "/{turnoverId}")
    public AjaxResult getInfo(@PathVariable("turnoverId") Long turnoverId)
    {
        return success(sceneryStoreTurnoverService.selectSceneryStoreTurnoverByTurnoverId(turnoverId));
    }

    /**
     * 新增营收管理
     */
    @PreAuthorize("@ss.hasPermi('scenery:turnover:add')")
    @Log(title = "营收管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SceneryStoreTurnover sceneryStoreTurnover)
    {
        return toAjax(sceneryStoreTurnoverService.insertSceneryStoreTurnover(sceneryStoreTurnover));
    }

    /**
     * 修改营收管理
     */
    @PreAuthorize("@ss.hasPermi('scenery:turnover:edit')")
    @Log(title = "营收管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SceneryStoreTurnover sceneryStoreTurnover)
    {
        return toAjax(sceneryStoreTurnoverService.updateSceneryStoreTurnover(sceneryStoreTurnover));
    }

    /**
     * 删除营收管理
     */
    @PreAuthorize("@ss.hasPermi('scenery:turnover:remove')")
    @Log(title = "营收管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{turnoverIds}")
    public AjaxResult remove(@PathVariable Long[] turnoverIds)
    {
        return toAjax(sceneryStoreTurnoverService.deleteSceneryStoreTurnoverByTurnoverIds(turnoverIds));
    }
}
